package 中断;

public class Interrupt中断忽略 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                while (!Thread.currentThread().isInterrupted()){
                    try {
                        for (int i = 0; i < 10; i++) {
                            System.out.println(i);
                            Thread.sleep(1000);
                        }
                    }catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
        t.start();
        //中断t线程
        Thread.sleep(3000);
        t.interrupt();
    }
}
